package com.cenwangkeji.zhihuimuye.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.cenwangkeji.zhihuimuye.R;
import com.cenwangkeji.zhihuimuye.model.bean.MonitoringBean;
import com.cenwangkeji.zhihuimuye.ui.activity.VideoActivity;
import com.cenwangkeji.zhihuimuye.ui.adapter.MonitoringAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.lws.basic.base.BaseFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * @松 on 2019/10/9 11:00
 */
public class MonitoringFragment extends BaseFragment implements BaseQuickAdapter.OnItemClickListener {
    @BindView(R.id.rv)
    RecyclerView mRv;
    Unbinder unbinder;

    @Override
    public int setLayoutId() {
        return R.layout.fragment_moitoring;
    }

    @Override
    protected void initView(View view) {
        super.initView(view);
        unbinder = ButterKnife.bind(this, view);
    }


    @Override
    protected void initData() {
        super.initData();
        initRecyeler();
    }

    private void initRecyeler(){
        List<MonitoringBean> list = new ArrayList<>();
        list.add(new MonitoringBean("0001"));
        list.add(new MonitoringBean("0002"));
        list.add(new MonitoringBean("0003"));
        list.add(new MonitoringBean("0004"));
        list.add(new MonitoringBean("0005"));
        list.add(new MonitoringBean("0006"));
        list.add(new MonitoringBean("0007"));
        list.add(new MonitoringBean("0008"));
        list.add(new MonitoringBean("0009"));

        mRv.setLayoutManager(new LinearLayoutManager(getContext()));
        MonitoringAdapter adapter = new MonitoringAdapter(list);
        adapter.openLoadAnimation(BaseQuickAdapter.SCALEIN);
        adapter.setOnItemClickListener(this);
        mRv.setAdapter(adapter);
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        startActivity(new Intent(getActivity(),VideoActivity.class));
    }
}
